package group2assignone.view.manager;

import group2assignone.func.UCCtoALAdapter;
import group2assignone.ucm.manager.*;
import group2assignone.view.OurView;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * manager view
 * @author group2
 */
public class ManagerView extends OurView {

    static private ManagerView instance;
    private JButton createFlight = new JButton("Create Flight");
    private JButton editFlight = new JButton("Edit Flight");
    private JButton addPromotion = new JButton("Add Promotion");
    private JButton editGST = new JButton("Edit GST");
    private JButton deleteFlight = new JButton("Delete Flight");
    private JButton addAirport = new JButton("Add Airport");
    private JButton editAirport = new JButton("Edit Airport");
    private JButton deleteAirport = new JButton("Delete Airport");
    private JButton logout = new JButton("Logout");
    private JLabel welcome = new JLabel();
    private String name = "username";

    private ManagerView() {
    }

    /**
     *
     * @param s
     */
    public void setUsername(String s) {
        name = s;
    }

    /**
     *
     * @return
     */
    static public ManagerView getInstance() {
        if (instance == null) {
            instance = new ManagerView();
        }

        return instance;
    }

    /**
     *
     * @param ucc
     */
//    public void setCreateFlightAL(UCCtoALAdapter ucc) {
//        createFlight.addActionListener(ucc);
//    }
//
//    /**
//     *
//     * @param ucc
//     */
//    public void setEditFlightAL(UCCtoALAdapter ucc) {
//        editFlight.addActionListener(ucc);
//    }
//
//    /**
//     *
//     * @param ucc
//     */
//    public void setDeleteFlightAL(UCCtoALAdapter ucc) {
//        deleteFlight.addActionListener(ucc);
//    }
//
//    /**
//     *
//     * @param ucc
//     */
//    public void setAddAirportAL(UCCtoALAdapter ucc) {
//        addAirport.addActionListener(ucc);
//    }
//
//    /**
//     *
//     * @param ucc
//     */
//    public void setEditAirportAL(UCCtoALAdapter ucc) {
//        editAirport.addActionListener(ucc);
//    }
//
//    /**
//     *
//     * @param ucc
//     */
//    public void setDeleteAirportAL(UCCtoALAdapter ucc) {
//        deleteAirport.addActionListener(ucc);
//    }
//
//    /**
//     *
//     * @param ucc
//     */
//    public void setLogoutAL(UCCtoALAdapter ucc) {
//        logout.addActionListener(ucc);
//    }

    @Override
    public void addComponents() {

        northPanel.add(welcome);
        centerPanel.setLayout(new GridLayout(2, 3, 20, 20));
        centerPanel.add(createFlight);
        centerPanel.add(editFlight);
        centerPanel.add(deleteFlight);
        centerPanel.add(addAirport);
        centerPanel.add(editAirport);
        centerPanel.add(deleteAirport);
        centerPanel.add(addPromotion);
        centerPanel.add(editGST);
        southPanel.add(logout);
        centerPanel.setBorder(BorderFactory.createEmptyBorder(50, 100, 50, 100));

        welcome.setText("Welcome, " + name);

        createFlight.addActionListener(new UCCtoALAdapter(new UCManagerUICreateFlight()));
        editFlight.addActionListener(new UCCtoALAdapter(new UCManagerUIEditFlight()));
        deleteFlight.addActionListener(new UCCtoALAdapter(new UCManagerUIDeleteFlight()));
        addAirport.addActionListener(new UCCtoALAdapter(new UCManagerUIAddAirport()));
        editAirport.addActionListener(new UCCtoALAdapter(new UCManagerUIEditAirport()));
        deleteAirport.addActionListener(new UCCtoALAdapter(new UCManagerUIDeleteAirport()));
        logout.addActionListener(new UCCtoALAdapter(new UCManagerLogout()));
        addPromotion.addActionListener(new UCCtoALAdapter(new UCManagerUIAddPromotion()));
        editGST.addActionListener((new UCCtoALAdapter(new UCManagerUIEditGST())));
    }

    /**
     *
     */
    public void clearGUI() {
        removeAll();
        repaint();
    }

    /**
     *
     * @param cr
     */
//    public void addCreateListener(ActionListener cr) {
//        createFlight.addActionListener(cr);
//    }

    /**
     *
     * @param ed
     */
//    public void addEditListener(ActionListener ed) {
//        editFlight.addActionListener(ed);
//    }
//
//    /**
//     *
//     * @param del
//     */
//    public void addDeleteListener(ActionListener del) {
//        deleteFlight.addActionListener(del);
//    }
//
//    /**
//     *
//     * @param lo
//     */
//    public void addLogoutListener(ActionListener lo) {
//        logout.addActionListener(lo);
//    }
}
